'use strict';
module.exports = (sequelize, DataTypes) => {
    const Profile = sequelize.define('profile', {
        id: {
            allowNull: false,
            autoIncrement: true,
            primaryKey: true,
            type: DataTypes.INTEGER
        },
        userId: {
            type: DataTypes.INTEGER,
            field: 'user_id',
            unique: true,
            allowNull: false,
            defaultValue: 0,
            references: {
                model: 'user',
                key: 'id'
            }
        },
        real_name: {
            type: DataTypes.STRING,
            allowNull: false,
            defaultValue: ''
        },
        useraddress: {
            type: DataTypes.STRING,
            allowNull: false,
            defaultValue: ''
        },
        mobile: {
            type: DataTypes.CHAR(12),
            unique: true,
            allowNull: false,
            defaultValue: ''
        },
        email: {
            type: DataTypes.STRING(50),
            unique: true,
            allowNull: false,
            defaultValue: ''
        },
        gender: {
            type: DataTypes.ENUM(['男', '女', '保密']),
            allowNull: false,
            defaultValue: '保密'
        },
        birthday: {
            type: DataTypes.DATE,
            allowNull: false,
        },
        createdAt: {
            allowNull: false,
            type: DataTypes.DATE,
            field: 'created_at'
        },
        updatedAt: {
            allowNull: false,
            type: DataTypes.DATE,
            field: 'updated_at'
        }
    }, {
        tableName: 'profile',
        charset: 'utf8mb4',
        collate: 'utf8mb4_bin'
    });
    Profile.associate = function (models) {
        this.belongsTo(models['user'], {
            foreignKey: 'userId'
        });
    };
    return Profile;
};